// import com.alibaba.druid.sql.ast.SQLExpr_ptr;
// import com.alibaba.druid.sql.ast.SQLObjectImpl;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor;

#include "SQLExternalRecordFormat.h"
#include "../../visitor/SQLASTVisitor.h"

// @Override
void SQLExternalRecordFormat::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLExternalRecordFormat)))
  {
    acceptChild(visitor, delimitedBy);
    acceptChild(visitor, terminatedBy);
    acceptChild(visitor, escapedBy);
    acceptChild(visitor, collectionItemsTerminatedBy);
    acceptChild(visitor, mapKeysTerminatedBy);
    acceptChild(visitor, linesTerminatedBy);
    acceptChild(visitor, nullDefinedAs);
    acceptChild(visitor, serde);
  }
  visitor->endVisit(SharedObject(SQLExternalRecordFormat));
}

SQLExpr_ptr SQLExternalRecordFormat::getDelimitedBy()
{
  return delimitedBy;
}

void SQLExternalRecordFormat::setDelimitedBy(SQLExpr_ptr delimitedBy)
{
  if (delimitedBy != nullptr)
  {
    delimitedBy->setParent(SharedObject(SQLExternalRecordFormat));
  }
  this->delimitedBy = delimitedBy;
}

SQLExpr_ptr SQLExternalRecordFormat::getTerminatedBy()
{
  return terminatedBy;
}

void SQLExternalRecordFormat::setTerminatedBy(SQLExpr_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLExternalRecordFormat));
  }
  this->terminatedBy = x;
}

SQLExpr_ptr SQLExternalRecordFormat::getSerde()
{
  return serde;
}

void SQLExternalRecordFormat::setSerde(SQLExpr_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLExternalRecordFormat));
  }
  this->serde = x;
}

SQLExpr_ptr SQLExternalRecordFormat::getMapKeysTerminatedBy()
{
  return mapKeysTerminatedBy;
}

void SQLExternalRecordFormat::setMapKeysTerminatedBy(SQLExpr_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLExternalRecordFormat));
  }
  mapKeysTerminatedBy = x;
}

SQLExpr_ptr SQLExternalRecordFormat::getCollectionItemsTerminatedBy()
{
  return collectionItemsTerminatedBy;
}

void SQLExternalRecordFormat::setCollectionItemsTerminatedBy(SQLExpr_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLExternalRecordFormat));
  }
  this->collectionItemsTerminatedBy = x;
}

SQLExpr_ptr SQLExternalRecordFormat::getEscapedBy()
{
  return escapedBy;
}

void SQLExternalRecordFormat::setEscapedBy(SQLExpr_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLExternalRecordFormat));
  }
  this->escapedBy = x;
}

SQLExpr_ptr SQLExternalRecordFormat::getLinesTerminatedBy()
{
  return linesTerminatedBy;
}

void SQLExternalRecordFormat::setLinesTerminatedBy(SQLExpr_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLExternalRecordFormat));
  }
  this->linesTerminatedBy = x;
}

SQLExpr_ptr SQLExternalRecordFormat::getNullDefinedAs()
{
  return nullDefinedAs;
}

void SQLExternalRecordFormat::setNullDefinedAs(SQLExpr_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLExternalRecordFormat));
  }
  this->nullDefinedAs = x;
}

BOOL_ptr SQLExternalRecordFormat::getLogfile()
{
  return logfile;
}

void SQLExternalRecordFormat::setLogfile(BOOL_ptr logfile)
{
  this->logfile = logfile;
}

BOOL_ptr SQLExternalRecordFormat::getBadfile()
{
  return badfile;
}

void SQLExternalRecordFormat::setBadfile(BOOL_ptr badfile)
{
  this->badfile = badfile;
}

BOOL_ptr SQLExternalRecordFormat::isLtrim()
{
  return ltrim;
}

void SQLExternalRecordFormat::setLtrim(BOOL_ptr ltrim)
{
  this->ltrim = ltrim;
}

BOOL_ptr SQLExternalRecordFormat::isRejectRowsWithAllNullFields()
{
  return rejectRowsWithAllNullFields;
}

void SQLExternalRecordFormat::setRejectRowsWithAllNullFields(BOOL_ptr rejectRowsWithAllNullFields)
{
  this->rejectRowsWithAllNullFields = rejectRowsWithAllNullFields;
}

BOOL_ptr SQLExternalRecordFormat::isMissingFieldValuesAreNull()
{
  return missingFieldValuesAreNull;
}

void SQLExternalRecordFormat::setMissingFieldValuesAreNull(BOOL_ptr missingFieldValuesAreNull)
{
  this->missingFieldValuesAreNull = missingFieldValuesAreNull;
}

SQLObject_ptr SQLExternalRecordFormat::clone()
{
  SQLObject_ptr clone_tmp = std::shared_ptr<SQLExternalRecordFormat>(new SQLExternalRecordFormat());
  std::shared_ptr<SQLExternalRecordFormat> x = std::dynamic_pointer_cast<SQLExternalRecordFormat>(clone_tmp);
  // SQLExternalRecordFormat x = new SQLExternalRecordFormat();

  if (delimitedBy != nullptr)
  {
    x->setDelimitedBy(std::dynamic_pointer_cast<SQLExpr>(delimitedBy->clone()));
  }

  if (escapedBy != nullptr)
  {
    x->setEscapedBy(std::dynamic_pointer_cast<SQLExpr>(escapedBy->clone()));
  }

  if (collectionItemsTerminatedBy != nullptr)
  {
    x->setCollectionItemsTerminatedBy(std::dynamic_pointer_cast<SQLExpr>(collectionItemsTerminatedBy->clone()));
  }

  if (mapKeysTerminatedBy != nullptr)
  {
    x->setMapKeysTerminatedBy(std::dynamic_pointer_cast<SQLExpr>(mapKeysTerminatedBy->clone()));
  }

  if (linesTerminatedBy != nullptr)
  {
    x->setLinesTerminatedBy(std::dynamic_pointer_cast<SQLExpr>(linesTerminatedBy->clone()));
  }

  if (nullDefinedAs != nullptr)
  {
    x->setNullDefinedAs(std::dynamic_pointer_cast<SQLExpr>(nullDefinedAs->clone()));
  }

  if (serde != nullptr)
  {
    x->setSerde(std::dynamic_pointer_cast<SQLExpr>(serde->clone()));
  }

  x->logfile = logfile;
  x->badfile = badfile;
  x->ltrim = ltrim;
  x->missingFieldValuesAreNull = missingFieldValuesAreNull;
  x->rejectRowsWithAllNullFields = rejectRowsWithAllNullFields;

  return x;
}
